import {defineStore} from "pinia";
import {ref} from "vue";

export const useUserStore = defineStore('student', () => {
        //存储用户信息
        const userInfo = ref({})

        //初始化用户信息
        const setUserInfo = (value) => {
            userInfo.value = value
        }
        //获取token
        const getToken = () => {
            return userInfo.value.token
        }
        //清空token
        const clearUserInfo = () => {
            userInfo.value = ''
        }

        return {
            userInfo, setUserInfo, getToken, clearUserInfo
        }

    }, {
        //持久化
        persist: true
    }
)
